package com.example.study;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

/**
 * @description：模拟调用超时失败
 * @author: liqiancheng
 * @createTime: 2021/8/19 10:39
 **/
public class MyHystrixCommand2 extends HystrixCommand<String> {

    private final String name;
    public MyHystrixCommand2(String name) {
        super(HystrixCommandGroupKey.Factory.asKey("MyGroup"));
        this.name = name;
    }
    @Override
    protected String run() {
        try {
            Thread.sleep(1000 * 10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return this.name + ":" + Thread.currentThread().getName();
    }
    @Override
    protected String getFallback() {
        return "失败了 ";
    }
}
